<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/passport.css?v=<?php echo Yii::app()->params['version']['CSS'];?>"/>
<div class="banner">
	<div class="wrap">
    	<div class="passport">
        	<!--<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/passport/login_ad.png" class="ad" alt="" />-->
            <ul class="passport_tab">
            	<li <?php if($method == "login"){?>class="cur"<?php }?>><i class="log"></i>登录</li>
            	<li <?php if($method == "register"){?>class="cur"<?php }?>><i class="reg"></i>注册</li>
            </ul>
            <div class="passport_con login" <?php if($method == "login"){?>style="display:block;"<?php }?>>
            	<p><input type="text" name="loginName" id="loginName" placeholder="输入邮箱/手机" /></p>
            	<p><input type="password" name="loginPasswd" id="loginPasswd" placeholder="输入密码******" /></p>
                <span><input type="checkbox" name="remember" id="remember" checked/><label for="remember">一个号月内保持帐号登陆</label></span>
                <a href="javascript:void(0);" class="passport_btn login">登录</a>
            </div>
            <div class="passport_con reg" <?php if($method == "register"){?>style="display:block;"<?php }?>>
            	<p><input type="text" name="registerName" id="registerName" placeholder="输入邮箱/手机" /><i>*用于登陆，不会公开,请输入正确的邮箱/手机号码</i></p>
            	<p><input type="password" name="registerPasswd" id="registerPasswd" placeholder="输入密码******" /><i>*请输入 6-12 位任意字符</i></p>
				<p><input type="password" name="repasswd" id="repasswd" placeholder="输入密码******" /><i>*请再次输入密码</i></p>
                <span><!--<input type="checkbox" name="" id="agree" checked disabled/><label for="agree">同意私家之旅<a href="javascript:;">会员条款</a></label>--></span>
                <a href="javascript:;" class="passport_btn register">注册</a>
            </div>
        </div>
    </div>
    <!--广告位-->
	<?php $this->beginWidget('application.widget.adver.passport'); ?>
	<?php $this->endWidget(); ?>
</div>
<script type="text/javascript">
new tabChange({tab:$(".passport .passport_tab li"),con:$(".passport .passport_con"),current:"cur",mouseEvent:"click"});
//用户注册
$(".passport_btn.register").on("click", function(){
	var registerName = $.trim($("#registerName").val());
	var registerPasswd = $.trim($("#registerPasswd").val());
	var repasswd = $.trim($("#repasswd").val());
	if(registerName == ""){
		$.jGrowl("用户名不能为空");
		return false;
	}
	if(registerPasswd == ""){
		$.jGrowl("密码不能为空");
		return false;
	}
	if(repasswd == ""){
		$.jGrowl("请输入确认密码");
		return false;
	}
	if(repasswd != registerPasswd){
		$.jGrowl("两次输入的密码不一致");
		return false;
	}
	var request = {};
	request.type = "post";
	request.url = "<?php echo Yii::app()->createUrl('passport/register');?>";
	request.dataType = "json";
	request.data = {registerForm:{username:registerName,password:registerPasswd,repasswd:repasswd}};
	request.error = function(){$.jGrowl("注册有点问题哦~,稍后再试试")};
	request.timeOut = 5000;
	request.success = function(msg){
		if(msg.header.status != 0){
			$.jGrowl(msg.header.reqMsg);
			return false;
		}
		location.href = msg.body.returnUrl;
	}
	$.ajax(request);
});
//用户登录
$(".passport_btn.login").on("click", function(){
	var loginName = $.trim($("#loginName").val());
	var loginPasswd = $.trim($("#loginPasswd").val());
	var rememberMe = $("#remember").is(":checked")?1:0;
	if(loginName == ""){
		$.jGrowl("用户名不能为空");
		return false;
	}
	if(loginPasswd == ""){
		$.jGrowl("密码不能为空");
		return false;
	}
	var request = {};
	request.type = "post";
	request.url = "<?php echo Yii::app()->createUrl('passport/login');?>";
	request.dataType = "json";
	request.data = {loginForm:{username:loginName, password:loginPasswd, rememberMe:rememberMe}};
	request.error = function(){$.jGrowl("登录有点问题哦~,稍后再试试")};
	request.timeOut = 5000;
	request.success = function(msg){
		if(msg.header.status != 0){
			$.jGrowl(msg.header.reqMsg);
			return false;
		}
		location.href = msg.body.returnUrl;
	}
	$.ajax(request);
});
</script>